package com.shortvedio.base.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shortvedio.base.model.dto.RelationInfo;
import com.shortvedio.base.model.po.UserRelationships;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserRelationshipsMapper extends BaseMapper<UserRelationships> {
    @Select("SELECT s_users_login.id,user_name,head_src FROM s_user_info LEFT JOIN s_users_login ON s_users_login.id=s_user_info.user_id WHERE s_user_info.`user_id` IN (SELECT target_user_id FROM user_relationships WHERE user_id = #{userId})")
    public List<RelationInfo> getRelationInfoList(Long userId);//获取关注的信息列表

    @Select("SELECT s_users_login.id,user_name,head_src FROM s_user_info LEFT JOIN s_users_login ON s_users_login.id=s_user_info.user_id WHERE s_user_info.`user_id` IN (SELECT user_id FROM user_relationships WHERE target_user_id = #{userId})")
    public List<RelationInfo> getFansInfoList(Long userId);//获取粉丝的信息列表

    @Select("SELECT s_users_login.id,user_name,head_src FROM s_user_info LEFT JOIN s_users_login ON s_users_login.id=s_user_info.user_id WHERE s_user_info.`user_id` IN (SELECT s1.target_user_id FROM user_relationships AS s1 LEFT JOIN user_relationships AS s2 ON s1.user_id=s2.target_user_id AND s1.target_user_id=s2.user_id WHERE s2.target_user_id = #{userId} )")
    public List<RelationInfo> getFriendList(Long userId);//获取朋友的信息列表
}
